/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 87111
 * Date: 2025-11-01
 * Time: 17:07
 */
//单例模式---饿汉式
class Singleton {
    private static Singleton instance = new Singleton();

    public static Singleton getInstance() {
        return instance;
    }
    private Singleton() {

    }
}
public class Demo1 {
    public static void main(String[] args) {
        //正确
        Singleton.getInstance();
//        //报错
//        Singleton singleton = new Singleton();
    }
}
